package org.idea.spring.bean.life;

import org.idea.spring.bean.life.beans.ApplicationProperties;
import org.idea.spring.bean.life.beans.LifeBean;
import org.springframework.beans.factory.support.DefaultSingletonBeanRegistry;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @Author linhao
 * @Date created in 8:28 上午 2021/6/7
 */
public class Application {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
//        applicationContext.addApplicationListener(new MyApplicationListener());
        applicationContext.register(Application.class);
        applicationContext.register(LifeBean.class);
        applicationContext.register(ApplicationProperties.class);
        applicationContext.refresh();
        ApplicationProperties applicationProperties = applicationContext.getBean(ApplicationProperties.class);
        System.out.println(applicationProperties.getUserId());
    }
//
//    public static class MyApplicationListener implements ApplicationListener{
//
//        @Override
//        public void onApplicationEvent(ApplicationEvent event) {
//            System.out.println(event);
//        }
//    }
}
